home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
basic
/
pbasmlib.zip
/
BIOS.DOC
< prev
next >
Wrap
Text File
|
1994-02-12
|
29KB
|
950 lines
PBASMLIB Assembly Language Routines for PB3C
Version 1.0
ROM BIOS Interface (BIOS.ASM)
(C) Copyright 1994 by Tim Gerchmez
All Rights Reserved.
This unit contains many routines that interface you to the ROM-BIOS
(Basic Input-Output System) in your computer. It is contained in
PBASMLIB.PBL, and will be immediately accessible to your programs by
including the statements $INCLUDE "PBASMLIB.INC" and $LINK "PBASMLIB.PBL"
at the top of your programs. Be careful with these routines, as they
provide you with much power and control, and a lot of potential to crash
the computer or cause damage to data/disks.
================================================================================
sub altprintscreen
Selects an alternate printscreen routine that
works if the screen length is not 25 lines. The
default always prints 25 lines.
Example: call altprintscreen
================================================================================
FUNCTION biosdiskstatus(d%)
Returns the status of the most recent BIOS disk operations.
d%: Set to drive (0=A, 1=B...) - Hard disks start with
128 (First=128, Second=129...)
biosdiskstatus: Returns error number:
0 = OK 1 = Invalid command 2 = Address mark not found
3 = Disk write protected 4 = Sector not found
5 = Reset failed 6 = Floppy disk removed
7 = Bad parameter table 8 = DMA overrun
9 = DMA crossed 64K boundary 10 = Bad sector flag
11 = Bad track flag 12 = Media type not found
13 = Invalid number of sectors on format
14 = Control data address mark detected
15 = DMA arbitration level out of range
16 = Uncorrectable CRC or ECC data error
17 = ECC corrected data error
32 = Controller failed
64 = Seek failed 128 = Disk timed out
170 = Drive not ready 187 = Undefined error
204 = Write fault 224 = Status register error
255 = Sense operation failed
Example: d%=biosdiskstatus(0)
================================================================================
FUNCTION biosdisktype(d%)
Returns type of drive installed for specified
floppy (PS/2 and PC/AT)
d%: Set to disk number (0=A:, 1=B: ...)
biosdisktype: Returns the following:
1 = 360K 5 1/4" 2 = 1.2MB 5 1/4"
3 = 720K 3 1/3" 4 = 1.44MB 3 1/2"
Other = unknown
Example: print biosdisktype(0)
================================================================================
sub biosresetfixed(d%)
Resets the fixed disk controller, recalibrates drives,
and prepares for subsequent disk I/O. Set d% to 128-255
(&H80-&Hff) - 128 for first fixed disk, 129 for second, etc.
d%: Set to hard disk to reset
Example: call biosresetfixed(128)
================================================================================
function bordercolor
Returns the color of the screen border (overscan).
Example: print bordercolor
================================================================================
sub capslockoff
Turns caps lock off
Example: call capslockoff
================================================================================
sub capslockon
Turns caps lock on
Example: call capslockon
================================================================================
function colregblock$(f??,ncr??)
Gets a group of consecutive color registers in
one operation.
f??: Set to first color register to be retrieved
ncr??: Set to number of color registers to retrieve
colregblock$: Returns a series of 3-byte entries for
red-green-blue (in that order), one entry for each color
register.
Example: c$=colregblock$(f??,ncr??)
================================================================================
function convmemsize
Returns size of conventional memory in KB.
Example: print convmemsize
================================================================================
function equipcode
Returns the BIOS equipment list code word.
equipcode: Returns code word (FN)
Bits Significance
---- ------------
14-15 Number of printers installed
13 1 if internal modem installed
12 1 if game adapter installed
9-11 Number of RS-232 ports installed
6-7 Number of floppy disks (00=1,01=2,10=3,11=4)
4-5 Initial video mode (01=40x25,10=80x25,11=monochrome)
2-3 System board RAM (PC) (00=16k,01=32k,10=48k,11=64k)
2 1 if pointing device installed (PS/2)
1 1 if math coprocessor installed
0 1 if floppy disk drive(s) installed
Example: print equipcode
================================================================================
sub fixeddiagnostic
Causes the fixed disk controller to perform a built-in
diagnostic self-test. Call BIOSDISKSTATUS afterwards
to determine if there were any errors.
No parameters.
Example: call fixeddiagnostic
================================================================================
sub getcharatr(pg%,ch%,atr%)
Gets the ASCII character and attribute at the current
cursor position for the specified page.
pg%: Set to page to read from
ch%: Returns character in ch%
atr%: Returns attribute in atr%
Example: getcharatr 0,ch%,atr%
================================================================================
sub getcolreg(rg%,g%,b%,r%)
Gets the contents of the specified color register. See
SETCOLREG.
rg%: Set to color register number to get values for
g%: Returns register value for green (0-255)
b%: Returns register value for blue (0-255)
r%: Returns register value for red (0-255)
Example: getcolreg 3,g%,r%,b%
================================================================================
sub getcolregpage(pg%)
Returns currently selected page of color registers
(see SETCOLREGPAGE).
m%: Returns current color register page selected.
Example: call getcolregpage(m%)
================================================================================
sub getconfiginfo(tpe%,mi%)
Gets configuration info for the active video subsystem
(EGA,VGA only).
tpe%: Returns display type (0 if color, 1 if mono)
mi%: Returns memory installed on EGA board
(0=64K, 1=128K, 2=192K, 3=256K)
Example: getconfiginfo tpe%,mi%
================================================================================
sub getcursorpos(pg%,ssl%,esl%,row%,col%)
Gets the position of the cursor on the display in text
coordinates, and the start/ending scan lines.
pg%: Set to screen page of cursor to read
ssl%: Returns start scan line of cursor (if visible)
esl%: Returns end scan line of cursor (if visible)
row%: Returns row location of cursor (1-25)
col%: Returns column location of cursor (1-80)
Example: getcursorpos 0,ssl%,esl%,row%,col%
================================================================================
sub getdisplaymode(x%,m%,adp%)
Gets the current display mode of the active video
controller.
x%: Returns number of character columns on screen (norm. 80)
m%: Returns display mode (see SETVIDEOMODE). Note that this
mode differs from what's used with the PB SCREEN statement.
adp%: Returns active display page
Example: getdisplaymode x%,m%,adp%
================================================================================
sub getfontinfo (code%,p??,r??,sg??,ofs??)
Returns a pointer to the character definition table for
a font, and returns information on that font.
code%: Set to the following font code -
00h = Current INT 1FH contents
01H = Current INT 43H contents
02H = ROM 8x14 font (VGA,EGA)
03H = ROM 8x8 font (chars 00H-7FH)
04H = ROM 8x8 font (chars 80H-FFH)
05H = ROM alternate 9x14 font (EGA,VGA)
06H = ROM 8x16 font (MCGA,VGA)
07H = ROM alternate 9x16 font (VGA)
p??: Returns points (bytes per character)
r??: Returns rows (char rows on screen - 1)
sg??: Returns segment of font table
ofs??: Returns offset of font table
Example: getfontinfo code%,p??,r??,sg??,ofs??
================================================================================
SUB getpagingmode(m%)
Gets the current paging mode for the color registers
(see SETPAGINGMODE). This command is not valid in
video mode 13h (320x200x256 graphics).
m%: Returns 0 if 4 pages of 64 registers is selected, or
1 if 16 pages of 16 registers is selected.
Example: call getpagingmode(m%)
================================================================================
sub getparallelports(lpt1??,lpt2??,lpt3??)
Gets the addresses for parallel ports 1-3.
if 0 returned, port is unavailable.
lpt1??,lpt2??,lpt3??: Returns printer port addresses
Example: getparallelports l1??,l2??,l3??
================================================================================
sub getpengraphpos(status%,y%,x%)
Gets the current status and position of the light pen
for graphics modes. For text mode, use GETPENPOS.
Example: getpengraphpos s%,y%,x%
================================================================================
sub getpenpos(status%,y%,x%)
Gets the current status and position of the light pen for
text modes. For graphics modes, use GETPENGRAPHPOS.
status%: Returns status (0=not down/triggered, 1=down/triggered)
y%: Returns character row (text Y coord) (normally 1-25)
x%: Returns character column (text X coord) (normally 1-80)
Example: getpenpos s%,y%,x%
================================================================================
sub getserialports(com1??,com2??,com3??,com4??)
Gets the addresses for COM ports 1-4.
if 0 returned, port is unavailable
com1??,com2??,com3??,com4??: Returns COM port addresses
Example: getserialports c1??,c2??,c3??,c4??
================================================================================
sub getsystype(mdl%,smdl%)
Retrieves the model and submodel numbers for the system
in use, allowing determination of system type.
mdl%: Returns MODEL value (see below)
smdl%: Returns SUBMODEL value (see below)
Machine Model Submodel
------- ----- --------
PC FFh
PC/XT FEh
PC/XT FBh 00h or 01h
PCjr FDh
PC/AT FCh 00h or 01h
PC/XT 286 FCh 02h
PC Convertible F9h
PS/2 Model 30 FAh 00h
PS/2 Model 50 FCh 04h
PS/2 Model 60 FCh 05h
PS/2 Model 80 F8h 00h or 01h
Example: getsystype mdl%,smdl%
================================================================================
sub insertoff
Turns insert mode off
Example: call insertoff
================================================================================
sub inserton
Turns insert mode on
Example: inserton
================================================================================
function isaltkey
Returns 1 if alt key pressed, 0 if not pressed.
Example: if isaltkey then print "alt key pressed"
================================================================================
function iscapslock
Returns 1 if capslock on, 0 if off
Example: print iscapslock
================================================================================
function iscrolock
Returns 1 if scroll lock is on, 0 if off.
Example: i% = iscrolock
================================================================================
function isctrlkey
Returns 1 if CTRL key is pressed, 0 if not
Example: print isctrlkey
================================================================================
function isdisk(d%)
Returns 1 if readable media is in a disk drive, or 0
if media is unreadable or no disk in drive.
d%: Set to disk number (0=A, 1=B... Hard Disks start at 128)
isdisk: Returns 1 if disk in drive, 0 if no disk in drive
Example: if isdisk(0) then open "i",#1,"A:\temp"
================================================================================
function isinsert
Returns 1 if insert mode is on, or 0 if off.
Example: print isinsert
================================================================================
function isleftshift
Returns 1 if left shift key pressed, 0 if not.
Example: a% = isleftshift
================================================================================
function isnumlock
Returns 1 if num lock is on, 0 if off.
Example: print isnumlock
================================================================================
function isrightshift
Returns 1 if right shift pressed, 0 if not
Example: rs% = isrightshift
================================================================================
sub loadfont (b%,tpe%)
Loads a ROM BIOS font and reprograms the video controller.
Do a mode set immediately before calling this routine
(See SETVIDEOMODE).
b%: Set to character generator block (normally 0)
tpe%: Set to type of font desired:
1: ROM 8x14 Font
2: ROM 8x8 Font
3: ROM 8x16 Font (MCGA/VGA Default)
Example: loadfont 0,2
================================================================================
sub loaduserfont(p%,b%,ncd%,fcc%,f$)
Loads a font table into the specified block of character
generator RAM and reprograms the video controller. This
function should be called only immediately after a mode set.
Page 0 of text mode must be active before calling.
p%: Set to points (bytes per character)
b%: Set to block of character generator RAM
ncd%: Set to number of characters defined by font table
fcc%: Set to first character code in table
f$: Set to font table string to be loaded
Example: loaduserfont p%,b%,ncd%,fcc%,f$
================================================================================
sub numlockoff
Turns numlock mode off.
Example: call numlockoff
================================================================================
sub numlockon
Turns num lock mode on
Example: numlockon
================================================================================
function palandbor$
Returns a 17-byte buffer describing the values in
palette registers 0-15, and screen border color (see
SETPALANDBOR). This PALETTE affects both text-mode and
graphics-mode colors, and will control what color is actually
displayed when using a certain number with the COLOR statement.
Example: s$=palandbor$
================================================================================
function palreg(r%)
Returns the color associated with the specified palette
register.
r%: Set to palette register to return value for
palreg: Returns color value
Example: a% = palreg(0)
================================================================================
sub pause (ms%)
Pauses for the specified time in milliseconds, using
the CMOS clock for timing (hardware-independent). One
millisecond is 1/1000 of a second. Smallest resolution of
the DELAY statement is about 50 milliseconds. This command
will only work on the AT and up.
ms%: Set to milliseconds to delay (up to about 32000, or
about 32 seconds maximum delay).
Example: pause 1000 'Pause for one second
================================================================================
sub pushcasc(sc%,ch%)
Pushes a character and scan code in the keyboard
type-ahead buffer.
sc%: Set to scan code
ch%: Set to character
Example: pushcasc 0,13
================================================================================
sub pushchrs(c$)
Pushes a string of characters into the
keyboard type-ahead buffer. Only the first
15 characters are accepted at once. Be sure to
add a CHR$(13) at the end if you want the command
execute upon program exit to DOS.
c$: Set to string to stuff into keyboard buffer
Example: pushchrs "dir/w"+chr$(13):shell
================================================================================
sub putchar(pg%,ch%,count%)
Puts an ASCII character to the display at
the current cursor position, using attribute
of previous character displayed at same position.
Example: putchar 0,65,32
================================================================================
sub putcharatr(pg%,ch%,atr%,count%)
Puts an ASCII character and attribute to the
display at the current cursor position.
pg%: Set to page to write to
ch%: Set to character to write
atr%: Set to attribute to write
count%: Set to number of characters to write
(replication factor). This can include
up to the whole screen in text mode, or
a single row in graphics modes.
Example: call putcharatr(0,15,65,1)
================================================================================
FUNCTION readpixel(pg%,y%,x%)
Returns the value of the graphics pixel on the specified
page at the specified coordinates.
pg%: Set to page to read
y%: Set to graphics y coordinate (row)
x%: Set to graphics x coordinate (column)
readpixel: Returns pixel value (0-255)
Example: a% = readpixel(0,102,95)
================================================================================
sub recalibratefixed(d%)
Causes the fixed disk adapter to recalibrate itself
and reposition the drive's arm to cylinder zero.
Call BIOSDISKSTATUS after to check for errors.
d%: Set to (128=first fixed disk, 129=second fixed disk)...
Example: recalibratefixed 128
================================================================================
sub resetdisks
Resets the disk controllers, recalibrates
attached drives, and prepares for disk I/O.
This function resets ALL drives present in system
including hard disk.
No parameters.
Example: call resetdisks
================================================================================
sub scrollockoff
Turns scroll lock mode off
Example: call scrollockoff
================================================================================
sub scrollockon
Turns scroll lock mode on
Example: call scrollockon
================================================================================
sub setblockspec(code%)
determines the character blocks selected by bit 3 of
attribute bytes in text modes.
code%: Set to block select code -
EGA,MCGA:
bits 0-1 = block selected by attribute bytes with bit 3 = 0
bits 2-3 = block selected by attribute bytes with bit 3 = 1
bits 4-7 = Not used, should be zero.
VGA:
bits 0,1,4 = block selected by attribute bytes with bit 3 = 0
bits 2,3,5 = block selected by attribute bytes with bit 3 = 1
bits 6,7 = Not used, should be zero.
Example: call setblockspec(code%)
================================================================================
sub setbordercolor(cl%)
Sets the color of the screen border (overscan).
cl%: Set to desired border color
Example: setbordercolor 12
================================================================================
sub setcolreg(rg%,g%,b%,r%)
Programs an individual color register with a red-green-blue
(RGB) combination value.
rg%: Set to color register number to change
g%: Set to value for green (0-255)
b%: Set to value for blue (0-255)
r%: Set to value for red (0-255)
Example: setcolreg 1,10,50,90
================================================================================
sub setcolregblock(f??,ncr??,c$)
Set a group of consecutive color registers in
one operation.
f??: Set to first color register to be set
ncr??: Set to number of color registers to be set
c$: Set to series of 3-byte entries for Red-Green-Blue
(in that order), one entry for each color register.
Example: setcolregblock f??,ncr??,c$
================================================================================
sub setcolregpage(pg%)
Selects a page of color registers (see SETPAGINGMODE).
pg%: Set to individual page of color registers to be selected.
Example: setcolregpage 3
================================================================================
sub setcursoremulation(c%)
Enables or disables cursor emulation for the
currently active video display. (VGA only)
c%: Set to 0 to enable or 1 to disable.
Example: setcursoremulation 0
================================================================================
sub setcursorpos(pg%, row%,col%)
Positions the cursor on the display, using text
coordinates. Does not update BASIC's cursor.
pg%: Set to screen page desired (normally 0)
row%: Set to Y coordinate desired (normally 1-25)
col%: Set to X coordinate desired (normally 1-80)
Example: setcursorpos 0,5,5
================================================================================
sub setcursortype(ssl%,esl%)
Sets starting and ending scan lines for the text-
mode cursor.
ssl%: Set to starting scan line desired (0-7)
esl%: Set to ending scan line desired (0-7)
Example: setcursortype 1,7
================================================================================
sub setdefaultfontvector (tpe%,rs%,rps??)
Sets the INT 43H vector to point to a ROM BIOS default
font and updates the video BIOS data area. Video controller
is not reprogrammed. Provides font selection in graphics modes.
tpe%: Set to desired font:
1 = ROM 8x14
2 = 8x8
3 = 8x16
rs%: Set to character rows specifier:
00 if user specified (specify in rps?)
01 = 14 rows
02 = 25 rows
03 = 43 rows
rps??: Set to rows per screen (if rs% = 0)
Example: call setdefaultfontvector(3,2,0)
================================================================================
sub setdisktype(d%,tpe%)
Selects a floppy disk type for the specified drive.
Not supported for the PC or PC/XT.
d%: Set to (0=A, 1=B)...
tpe%: Set to:
01 = 320/360K floppy in 360K drive
02 = 320/360K floppy in 1.2MB drive
03 = 1.2MB floppy in 1.2MB drive
04 = 720K floppy in 720K drive
Example: setdisktype 0,1
================================================================================
sub setdisplaypage(pg%)
Selects the active display page for the video display.
(0 is the default display page).
pg%: Set to page to display. Ranges are as follows:
0-7 for modes 00H/01H (CGA,EGA,MCGA,VGA)
0-3 for modes 02H/03H (CGA)
0-7 for modes 02H/03H (EGA,MCGA,VGA)
0-7 for mode 07H (EGA,VGA)
0-7 for mode 0DH (EGA,VGA)
0-3 for mode 0EH (EGA,VGA)
0-1 for mode 0FH (EGA,VGA)
0-1 for mode 10H (EGA,VGA)
Example: setdisplaypage 0
================================================================================
sub setfontpointer(sg??,ofs??)
Sets the INT 1FH font pointer to the user's font table.
This table is used by char. codes 80H-FFH in graphics
modes 04H-06H. Provides font selection in graphics modes.
sg??: Set to segment of font table
ofs??: Set to offset of font table
Example: setfontpointer sg??,ofs??
================================================================================
sub setfontvector(rs%,p??,rps??,sg??,ofs??)
Sets the INT 43H vector to point to the user's font table
and updates the ROM BIOS data area. Video controller is not
reprogrammed. Provides font selection in graphics modes.
rs%: Set to character rows specifier:
00 if user specified (specify in rps??)
01 = 14 rows
02 = 25 rows
03 = 43 rows
p??: Set to points (bytes per character)
rps??: Set to rows per screen (if rs% = 0)
sg??: Set to segment of font table
ofs??: Set to offset of font table
Example: setfontvector rs%,p??,rps??,sg??,ofs??
================================================================================
sub setgrayscale(f??,ncr??)
Transforms the RGB values of one or more color registers
into their gray-scale equivalents. The original red, green
and blue values that were in the registers are lost.
Doing this in text modes produces some interesting effects.
f??: Set to first color register to change
ncr??: Set to number of color registers to change
Example: setgrayscale 0,255
================================================================================
sub setgraysumming(c%)
Enables or disables gray-scale summing for the
active video display.
c%: Set to 0 to enable or 1 to disable.
Example: setgraysumming b%
================================================================================
sub setpagingmode(m%)
Selects a paging mode for the color registers.
m%: Set to 0 for 4 pages of 64 registers, or 1
for 16 pages of 16 registers. Not valid in
mode 13h (320x200x256 graphics).
Example: setpagingmode 1
================================================================================
sub setpalandbor(c$)
Sets all palette registers and screen border in
one operation.
c$: Set to string consisting of 16 one-byte color values
to be loaded into palette regs 0-15, and one byte for border
color (17 bytes total).
Example: setpalandbor c$
================================================================================
sub setpaletteloading(c%)
Enables or disables default palette loading when a video
mode is set.
c%: Set to 0 to enable, or 1 to disable.
Example: call setpaletteloading(c%)
================================================================================
sub setpalreg(cv%,pr%)
Sets the correspondence of a palette register to
a displayable color.
cv%: Set to color value (EGA/VGA; 7 only on MCGA)
pr%: Set to palette register (0-15 EGA/VGA; 18 only on MCGA)
Example: setpalreg 5,8
================================================================================
sub setparallelports(lpt1??,lpt2??,lpt3??)
Sets the addresses for parallel ports 1-3
(see GETPARALLELPORTS).
lpt1??,lpt2??,lpt3??: Set to printer port addresses desired
Example: setparallelports l1??,l2??,l3??
================================================================================
sub setrepeatrate(rt%,dly%)
Sets the ROM BIOS key repeat rate and delay.
rt%: Set to desired rate: 00H-1FH = 30.0 to 2.0 chars per second
dly%: Set to desired delay: 00H-03H = 250msec-1000msec
Example: setrepeatrate 0,0
================================================================================
sub setscanlines(code%)
Sets number of scan lines for text modes. Selection
takes effect next time SETVIDEOMODE is used to set mode.
(VGA only)
Code%: Set to-
00H = 200 scan lines (CGA Resolution)
01H = 350 scan lines (EGA Resolution)
02H = 400 scan lines (VGA Resolution)
Example: setscanlines 0
================================================================================
sub setscreenrefresh(c%)
Enables or disables the video refresh for currently
active display. This effectively blanks the screen
while disabled, and may slightly speed up the computer.
VGA Only.
c%: Set to 0 to enable or 1 to disable
Example: call setscreenrefresh(0)
================================================================================
sub setserialports(com1??,com2??,com3??,com4??)
Sets the addresses for COM ports 1-4 (see GETSERIALPORTS).
com1??,com2??,com3??,com4??: Set to serial port addresses desired
Example: setserialports c1??,c2??,c3??,c4??
================================================================================
sub setvideomode(m%)
Sets the current video display mode and active
video controller
m%: Set to video mode desired. A few of those
available are:
00H - 40x25 text, 16 color, color burst off
01H - 40x25 text, 16 color
02H - 80x25 text, color burst off
03H - 80x25 text, 16 color (default)
04H - 320x200 graphics, 4 colors
05H - 320x200 graphics, 4 colors, color burst off
06H - 640x200, graphics, 2 colors
07H - 80x25 text, 2 colors (monochrome only)
Example: setvideomode 3
================================================================================
sub setvideorefresh(c%)
Enables or disables CPU access to video adapter's
I/O ports and video refresh buffer.
c%: Set to 0 to enable access or 1 to disable access.
Example: setvideorefresh 0
================================================================================
sub toggleblink(t%)
Determines whether most significant bit of
a character attribute will select blinking or
intensity. Toggle on for 8 extra char. background
colors (must be set using FOREGROUND color + 16
with desired background color (COLOR X+16,Y).
t%: Set to 0 for intensity or 1 for blinking.
Example: toggleblink 0
================================================================================
sub writepixel(pg%,y%,x%,pv%)
Draws a point on the graphics display at the
specified coordinate. The ranges of valid values
depend on the current video mode.
pg%: Set to page to write to
y%: Set to graphics Y coordinate (row)
x%: Set to graphics X coordinate (column)
pv%: Set to pixel value to write (0-255)
Example: writepixel 0,34,92,127